home *** CD-ROM | disk | FTP | other *** search
/ How to Get Online 1996 Spring / HOW2GON.ISO / mac / FTP / Robert's File Server v1. folder / Robert's File Server v1.10 / For Eudora Pro / File server v1.10 (TEXT) next >
Text File  |  1995-10-31  |  8KB  |  190 lines

  1. -- Settings
  2. set eudoraSettings to {alias "Macintosh HD:Documents:file-server Folder:Eudora Settings"}
  3. set pubdir to "Macintosh HD:Accès ARA:De Robert:" -- the folder whare the files are
  4. set indexFile to {alias "Macintosh HD:Accès ARA:De Robert:00index.txt"} -- the files list
  5. set inMailbox to "In" -- the name of the incomming mailbox
  6. set trashMailbox to "Reçus et traités" -- the name of the trash mailbox we want to use
  7. set outMailbox to "Out" -- the name of the outgoing messages
  8. set formsMailbox to "Modèles" -- the name of our forms mailbox
  9. set sysop to "robert" -- who will get the Bcc of error reports if any
  10. set returnPath to "" as string -- initialize
  11. set myType to "" -- initialize
  12.  
  13. -- First check if Eudora is already running. If so, exit with a nice beep.
  14. -- I don't want the script to throw me out my messages reading when I'm
  15. -- using Eudora. This part of the script requires the GTQ Scripting Library's
  16. -- "Is Application Running" scripting addition.
  17. if (is application running "Eudora Pro") then
  18.     beep
  19.     return
  20. end if
  21.  
  22. -- Now the script itself.
  23. tell application "Eudora Pro"
  24.     activate
  25.     -- If not using the default Eudora's Settings open it here
  26.     open eudoraSettings
  27.     with timeout of 3600 seconds
  28.         -- get the messages from server
  29.         connect with checking
  30.         -- do we have incomming messages?
  31.         set messageCount to (count mailbox named inMailbox of mail folder named "" each message)
  32.         if messageCount is not 0 then
  33.             -- so process them
  34.             set itemNumber to 1
  35.             repeat messageCount times
  36.                 -- get the body of the message
  37.                 -- we cannot get the body of a message with Eudora Pro (2.13)
  38.                 -- this part will extract it from the entire message
  39.                 set messageText to message itemNumber of mailbox named inMailbox of mail folder named ""
  40.                 set lineCount to (count the paragraphs of messageText)
  41.                 set lineTodo to 1
  42.                 -- process each line
  43.                 repeat lineCount times
  44.                     set theLine to paragraph lineTodo of messageText
  45.                     set wordCount to (count the words of theLine)
  46.                     if wordCount is not 0 then
  47.                         set myCommand to the first word of theLine
  48.                         if (myCommand is "path") and (wordCount > 1) then
  49.                             set returnPath to characters 6 thru (the ¬
  50.                                 length of theLine) of theLine as string
  51.                         else if myCommand is "AppleDouble" then
  52.                             set myType to myCommand
  53.                         else if myCommand is "AppleSingle" then
  54.                             set myType to myCommand
  55.                         else if myCommand is "BinHex" then
  56.                             set myType to myCommand
  57.                         else if myCommand is "uuencode" then
  58.                             set myType to myCommand
  59.                         else if (myCommand is "help") ¬
  60.                             or (myCommand is "aide") then
  61.                             -- Instead of attaching a file, we get
  62.                             -- the content of a saved message and paste
  63.                             -- it into the reply.
  64.                             reply message itemNumber of mailbox inMailbox ¬
  65.                                 of mail folder named "" without quoting
  66.                             if returnPath is not "" then
  67.                                 set field "To:" of message named "" to returnPath
  68.                             end if
  69.                             set the field "Subject:" of message named "" to myCommand
  70.                             -- now get the body of the saved message
  71.                             -- first locate the message itself
  72.                             set foundForm to 1
  73.                             repeat (count mailbox named formsMailbox ¬
  74.                                 of mail folder named "" each message) times
  75.                                 if the field "Subject:" of message foundForm ¬
  76.                                     of mailbox formsMailbox of mail folder "" ¬
  77.                                     contains myCommand then
  78.                                     exit repeat
  79.                                 else
  80.                                     set foundForm to foundForm + 1
  81.                                 end if
  82.                             end repeat
  83.                             -- get the body of the message
  84.                             -- we cannot get the body of a message with Eudora Pro (2.13)
  85.                             -- this part will extract it from the entire message
  86.                             -- the body start at a line beginning with "X-Attachments:"
  87.                             -- (Don't ask me why!!!!)
  88.                             set myForm to message foundForm of mailbox named formsMailbox of mail folder ""
  89.                             set myOffset to the offset of "X-Attachments:" in myForm
  90.                             set myLength to the length of myForm
  91.                             set myForm to (characters (myOffset + 14) thru myLength of myForm) as text
  92.                             -- as the length of "X-Attachments:" is 14
  93.                             -- paste it
  94.                             set the body of message named "" to myForm
  95.                             -- send the message
  96.                             queue message named ""
  97.                         else if myCommand is "index" then
  98.                             -- send the "00index.txt" file
  99.                             reply message itemNumber of mailbox inMailbox ¬
  100.                                 of mail folder named "" without quoting
  101.                             if returnPath is not "" then
  102.                                 set field "To:" of message named "" to returnPath
  103.                             end if
  104.                             set the field "Subject:" of message named "" to "Index"
  105.                             set the body of message named "" ¬
  106.                                 to ("This is the files list of our file server." ¬
  107.                                 & return & return ¬
  108.                                 & "To receive the help file, put the word «help»" ¬
  109.                                 & " in the body of your message." & return)
  110.                             if myType is "AppleSingle" then
  111.                                 set attachment encoding of message named "" to AppleSingle
  112.                             else if myType is "BinHex" then
  113.                                 set attachment encoding of message named "" to BinHex
  114.                             else if myType is "uuencode" then
  115.                                 set attachment encoding of message named "" to uuencode
  116.                             else
  117.                                 set attachment encoding of message named "" to AppleDouble
  118.                             end if
  119.                             attach to message named "" documents indexFile
  120.                             queue message named ""
  121.                         else if (myCommand is "send") and (wordCount > 1) then
  122.                             -- send a file
  123.                             reply message itemNumber of mailbox inMailbox ¬
  124.                                 of mail folder named "" without quoting
  125.                             if returnPath is not "" then
  126.                                 set field "To:" of message named "" to returnPath
  127.                             end if
  128.                             -- get the file name
  129.                             set fName to characters 6 thru (the length of theLine) ¬
  130.                                 of theLine as string
  131.                             set field "Subject:" of message named "" to fName
  132.                             try
  133.                                 -- try to attach the file
  134.                                 set the body of message named "" ¬
  135.                                     to "This is the file you requested." & return & return ¬
  136.                                     & "To receive the help file, put the word «help»" ¬
  137.                                     & " in the body of your message, to receive our files list, " ¬
  138.                                     & "put the word «index»." & return
  139.                                 if myType is "AppleSingle" then
  140.                                     set attachment encoding of message named "" to AppleSingle
  141.                                 else if myType is "BinHex" then
  142.                                     set attachment encoding of message named "" to BinHex
  143.                                 else if myType is "uuencode" then
  144.                                     set attachment encoding of message named "" to uuencode
  145.                                 else
  146.                                     set attachment encoding of message named "" to AppleDouble
  147.                                 end if
  148.                                 attach to message named "" documents {alias (pubdir & fName)}
  149.                             on error errorText
  150.                                 -- the file wasn't there???
  151.                                 set the body of message named "" ¬
  152.                                     to "Error while processing the «send» command for the file: «" ¬
  153.                                     & fName & "», probably because the file doesn't exists." & return ¬
  154.                                     & return & "To receive the help file, put the word «help»" ¬
  155.                                     & " in the body of your message, to receive our files list, " ¬
  156.                                     & "put the word «index»." & return & return ¬
  157.                                     & "The message returned by AppleScript: " & errorText & return
  158.                                 set the field "Bcc:" of message named "" to sysop
  159.                             end try
  160.                             queue message named ""
  161.                         end if
  162.                     end if
  163.                     set lineTodo to lineTodo + 1
  164.                 end repeat
  165.                 -- re-initialize variables
  166.                 set returnPath to "" as string
  167.                 set myType to ""
  168.                 set itemNumber to itemNumber + 1
  169.             end repeat
  170.             -- move messages to our trash mailbox
  171.             repeat messageCount times
  172.                 move message 1 of mailbox inMailbox of mail folder named "" ¬
  173.                     to the end of mailbox trashMailbox of mail folder named ""
  174.             end repeat
  175.             -- the same for sent messages
  176.             -- after sending them
  177.             set messageCount to (count mailbox named outMailbox ¬
  178.                 of mail folder named "" each message)
  179.             if (messageCount > 0) then
  180.                 connect with sending
  181.                 repeat messageCount times
  182.                     move message 1 of mailbox outMailbox of mail folder named "" ¬
  183.                         to the end of mailbox trashMailbox of mail folder named ""
  184.                 end repeat
  185.             end if
  186.         end if
  187.         quit -- Bye
  188.     end timeout
  189. end tell
  190.